# import cv2
import cv2 as cv

# if cannot understand copy the function name then search on OpenCV documentation

#Task1
# source image path
filename = '/Users/charles/Desktop/CSDN_AI_Enginner/Resource/Lena.png'
# image input
img = cv.imread(filename)

# GaussianBlur Image
imgGauss = cv.GaussianBlur(img, (3,3), 0)
# Resize Image
image1 = cv.resize(img,(int(img.shape[1]/2), int(img.shape[0]/2)))
# Blurs image1 and downsamples it
image2 = cv.pyrDown(image1)

gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
_, gray1 = cv.threshold(gray, 120, 0xff, cv.THRESH_BINARY)

# Show 6 images
cv.imshow("source image", img)
cv.imshow("Gaussian filtered image", imgGauss)
cv.imshow("half size", image1)
cv.imshow("quarter size", image2)
cv.imshow("gray", gray)
cv.imshow("threshold image", gray1)

#Task2
#Convert color model of Source image from BGR to HSV
hsv = cv.cvtColor(img, cv.COLOR_BGR2HSV)

# show SHV Channel
cv.imshow("Hue", hsv[:,:,0])
cv.imshow("Saturation", hsv[:,:,1])
cv.imshow("Value", hsv[:,:,2])
# show BGR Channel
cv.imshow("Blue", img[:,:,0])
cv.imshow("Green", img[:,:,1])
cv.imshow("Red", img[:,:,2])

# Exit and destroy all windows
cv.waitKey()
cv.destroyAllWindows()